<?php
/*
 * 手机客户端店铺-店铺首页接口
 * 2014-02-21
 * 2014-05-08 (已查) 
 */
include "inc/public_header.php";


$reJson = array(); //构建返回值

/*
 * 常量
 */

$img_Path = "http://www.chinalaohu.com/img1/uploads/imgissue/";
$img_pinPath = "http://www.chinalaohu.com/images/shop/logo/";
$img_xuexiaoPath = "http://www.chinalaohu.com/images/shop/xuexiao/";

$reJson["success"] = "1";

//店铺首页滚动图片信息
$sql = "select * from home_scroll_ad where acode='1'"; 
$db->query($sql);
$logoArr = array();
while($db->next_record()){
	$type	   = $db->f("type");
	if ($type == 1){
		$shopId = "";
		$category = "";
		$wapUrl	= $db->f("wapurl");
	}else{
		$parameter = explode(",",$db->f("parameter"));
		$shopId = $parameter[0];
		if (!$shopId){
			$shopId="";
		}
		$collegeId = $parameter[1];
		if (!$collegeId){
			$collegeId="";
		}
		$category = $parameter[2];
		if (!$category){
			$category="";
		}
		$wapUrl	= "";
	}
	$logoArr[] = array(
		"imgUrl"=>$img_Path.$db->f("apath")				//图片地址
		,"type"=>$type							//类型
		//,"shopId"=>$shopId				//店铺id
		,"shopId"=>"86"				//店铺id
		//,"collegeId"=>$collegeId
		,"collegeId"=>""
		,"category"=>$category				//分类
		,"title"=>$db->f("title")						//标题
		,"wapUrl"=>$wapUrl						//网页地址

	);
}			
//放入店铺首页滚动图片信息
$reJson["logo"] = $logoArr;


$daofangArr1[] = array(
		"imgUrl"=>"http://www.chinalaohu.com/modules/miniature.php?w=150&h=150&p=/uploads/zjl_ilogo/1.jpg"			
		,"title"=>"大全套表"
		,"shopId"=>"86"		
	);
$daofangArr1[] = array(
		"imgUrl"=>"http://www.chinalaohu.com/modules/miniature.php?w=150&h=150&p=/uploads/zjl_ilogo/2.jpg"			
		,"title"=>"小全套表"
		,"shopId"=>"81"		
	);
$daofangArr1[] = array(
		"imgUrl"=>"http://www.chinalaohu.com/modules/miniature.php?w=150&h=150&p=/uploads/zjl_ilogo/4.jpg"			
		,"title"=>"大学生表"
		,"shopId"=>"87"		
	);
$daofangArr1[] = array(
		"imgUrl"=>"http://www.chinalaohu.com/modules/miniature.php?w=150&h=150&p=/uploads/zjl_ilogo/5.jpg"			
		,"title"=>"孙信德表"
		,"shopId"=>"88"		
	);
$daofangArr1[] = array(
		"imgUrl"=>"http://www.chinalaohu.com/modules/miniature.php?w=150&h=150&p=/uploads/zjl_ilogo/3.jpg"			
		,"title"=>"墨屏"
		,"shopId"=>"92"		
	);
$daofangArr1[] = array(
		"imgUrl"=>"http://www.chinalaohu.com/modules/miniature.php?w=150&h=150&p=/uploads/zjl_ilogo/6.jpg"			
		,"title"=>"把玩件"
		,"shopId"=>"93"		
	);
$daofangArr[] = $daofangArr1;
$reJson["daofang"] = $daofangArr;

$sql = "select c.id,c.aname,sum(b.goodsCount) gc from new_weituo_person a 
              inner join 
				(select e.uid,e.shop_id,e.goodsCount from shop_info d inner join (select uid,shop_id,count(product_id) as goodsCount from shop_product where shangjia='1' GROUP BY shop_id) e on d.shop_id=e.shop_id
				where d.renzhen_flag=1) b on a.uid=b.uid
							INNER JOIN
							new_weituo_xuexiao c on a.xuexiao_id=c.id
				where a.xuexiao_id is not null and a.xuexiao_id!='1' GROUP BY a.xuexiao_id ORDER BY gc desc"; 
$db->query($sql);
$laohuArr = array();
while($db->next_record()){
	$laohuArr[] = array(
		"imgUrl"=>$img_xuexiaoPath.$db->f("id").".jpg"				//图片地址
		,"title"=>$db->f("aname")			//学校名称
		,"collegeId"=>$db->f("id")							//学校id
	);
}
		

$reJson["laohu"] = $laohuArr;

//店铺品牌馆信息
$sql = "select * from shop_info where pin_type=1 and renzhen_flag=1 order by pin_no asc,shop_id desc"; 
$db->query($sql);
$brandArr = array();
while($db->next_record()){
	$brandArr[] = array(
		"imgUrl"=>$img_pinPath.$db->f("shop_id").".jpg?1"				//图片地址
		,"shopId"=>$db->f("shop_id")							//店铺id
		,"title"=>$db->f("pin_name")			//店铺名称
	);
}
		
//放入店铺品牌馆信息
$reJson["brand"] = $brandArr;

echo json_encode($reJson);
?>
